#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct ListNode{
	char data;
	struct ListNode *next;
};

struct ListNode* reverse1(struct ListNode* head){
	if(head == NULL||head->next == NULL)
	return head;

	struct ListNode *n1 = NULL;
	struct ListNode *n2 = head;
	struct ListNode *n3 = head->next;

	while(n2)
	{
		n2->next = n1;
		n1 = n2;
		n2 = n3;
		if(n3)
		n3 = n3->next;
	}
	return n1;
}

struct ListNode* reverse2(struct ListNode* head){
	struct ListNode* cur = head;
	struct LisrNode* newhead = NULL;
	while(cur)
	{
		struct ListNode* next = cur->next;
		cur->next = newhead;
		newhead = cur;
		cur = next;	
	}
	return newhead;
}
//int main(int argc,char * argv[])
//int main(int argc,char *argv[])
int main(int argc,char* argv[])
{	
	struct ListNode* head;
	struct ListNode* pend;
	struct ListNode* pnew;
	head = (struct ListNode*)malloc(sizeof(struct ListNode));
	head->next = NULL;
	pend = head;
	int i = 1;
	while(i<argc)
	{
	        pnew = (struct ListNode*)malloc(sizeof(struct ListNode));
		pnew->data = *argv[i++];
		pnew->next = NULL;
		//pnew->next = pend;
		pend->next = pnew;
		pend = pnew;//caution!
	}
	head = head->next;
	struct ListNode* scope = reverse1(head);
	argc--;
	while(argc--)
	{
		printf("%c ",scope->data);
		scope = scope->next;	
	}
	printf("\n");
	return 0;
}
